package org.example.exception;

import org.example.entity.AjaxResult;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionAdvice {
    @ExceptionHandler(value = LoginException.class)
    public AjaxResult handleLoginException(LoginException ex){
        return AjaxResult.err(401, ex.getMessage());
    }

//    @ExceptionHandler(value = NoPermsException.class)
//    public AjaxResult handleLoginException(NoPermsException ex){
//        return AjaxResult.err(403, ex.getMessage());
//    }

    @ExceptionHandler(value = Exception.class)
    public AjaxResult handleLoginException(Exception ex){
        return AjaxResult.err(ex.getMessage());
    }

}
